package com.qinghuan.designMode.prePrinciple.inversion;

/**
 * @Auther: qinghuan
 * @Date: 2022/2/17 19:11
 * @Description:依赖倒转
 * 1.高层模块不应该依赖低层模块，二者都应该依赖其抽象
 * ★2.抽象不应该以来细节，细节应该依赖抽象
 * 3.依赖倒转的中心思想是面向接口编程
 */
public class DenpencyInversion {

    public static void main(String[] args) {
        Person person = new Person();
        person.receive(new Email());
    }

}

interface IServicer{
    void getInfo();
}

class Email implements IServicer{
    public void getInfo() {
        System.out.println("hello world!");
    }
}

class WeChat implements IServicer{
    public void getInfo(){
        System.out.println("hello wechat!");
    }
}

//接受邮件
class Person{
    void receive(IServicer servicer) {
        servicer.getInfo();
    }
}
